home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / snip0493.zip / NOCTRLC.C < prev    next >
C/C++ Source or Header  |  1993-04-05  |  2KB  |  64 lines

  1. /****************************************************************/
  2. /* Name: noctrl()                                               */
  3. /* Desc: captures interrput 9 so as to ignore ctrl-c,ctrl-break,*/
  4. /*       ctrl-alt-del                                           */
  5. /****************************************************************/
  6.  
  7. #include <dos.h>
  8.  
  9. #if defined(__ZTC__)
  10.  #define INTERRUPT
  11.  #define FAR            _far
  12.  #define ENABLE         int_on
  13.  #define INPORTB        inp
  14.  #define OUTPORTB       outp
  15. #else
  16.  #include <conio.h>
  17.  #if defined(__TURBOC__)
  18.   #define INTERRUPT      interrupt
  19.   #define FAR            far
  20.   #define ENABLE         enable
  21.   #define INPORTB        inportb
  22.   #define OUTPORTB       outportb
  23.  #else
  24.   #define INTERRUPT      _interrupt
  25.   #define FAR            _far
  26.   #define ENABLE         _enable
  27.   #define INPORTB        inp
  28.   #define OUTPORTB       outp
  29.  #endif
  30. #endif
  31.  
  32. extern void (INTERRUPT FAR *oldint9)(void);     /* Caller must set this */
  33.  
  34. void INTERRUPT FAR noctrl(void)
  35. {
  36.       unsigned char byte;
  37.       static int flag;
  38.  
  39.       ENABLE();
  40.  
  41.       if ((byte = (unsigned char)INPORTB(0x60)) == 29)
  42.             flag = 1;
  43.  
  44.       if (byte == 157)
  45.             flag = 0;
  46.  
  47.       if (!flag)
  48.             (*oldint9)();
  49.       else  switch (byte)
  50.       {
  51.       case 46 :   /* yeah, these should be #defined! */
  52.       case 70 :
  53.       case 56 :
  54.       case 83 :
  55.             byte = (unsigned char)INPORTB(0x61);
  56.             OUTPORTB(0x61,byte | 0x80);
  57.             OUTPORTB(0x61,byte);
  58.             OUTPORTB(0x20,0x20);
  59.             break;
  60.       default :
  61.             (*oldint9)();
  62.       }
  63. }
  64.